#include "Timer.h"
#include "SDL.h"

CTimer::CTimer(void) :
	m_delta(seconds(0)), m_timeStart(), m_timeEnd()
{
}
CTimer::~CTimer(void)
{
}
void CTimer::Start()
{
	m_timeStart = microsec_clock::local_time();
	m_bRunning = true;
}
void CTimer::Stop()
{
	if(m_bRunning)
	{
		m_bRunning = false;
		m_timeEnd = microsec_clock::local_time();
		m_delta = (m_timeEnd - m_timeStart);
	}
}
double CTimer::GetTimeDelta() { 
	//Make total seconds in double format from tick count
	return (double)((double)m_delta.ticks() / (double)microsec_clock::time_duration_type::ticks_per_second());
}
double CTimer::GetTimeRunning() { 
	time_duration delta = microsec_clock::local_time() - m_timeStart;;

	//Make total seconds in double format from tick count
	return (double)((double)delta.ticks() / (double)microsec_clock::time_duration_type::ticks_per_second());
} 
ulong CTimer::GetTickCount()
{
	return (ulong)m_delta.ticks() / microsec_clock::time_duration_type::ticks_per_second() * 1000.0f;
}
ptime CTimer::GetTimeStart() { return m_timeStart; }
ptime CTimer::GetTimeEnd() { return m_timeEnd; }
bool CTimer::IsRunning() { return m_bRunning; }
time_duration CTimer::GetTimeRunningDuration() { return microsec_clock::local_time() - m_timeStart; }
